package com.cheung.leetcode.normal;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class LC26 {
    public int removeDuplicates(int[] nums) {
        List<Integer> list = new ArrayList<>();
        list.add(nums[0]);
        for (int num : nums) {
            if (num > list.get(list.size() - 1)) {
                list.add(num);
            }
        }
        for (int i = 0; i < list.size(); i++) {
            nums[i] = list.get(i);
        }

        return list.size();
    }

    public static void main(String[] args) {

        int[] nums = {0, 0, 1, 1, 1, 2, 2, 3, 3, 4};
        System.out.println(new LC26().removeDuplicates(nums));
        System.out.println(Arrays.toString(nums));
    }
}
